\(\int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx\) [234]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 42 \[ \int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=(a A-b B) x-\frac {(A b+a B) \log (\cos (c+d x))}{d}+\frac {b B \tan (c+d x)}{d} \]

[Out]

(A*a-B*b)*x-(A*b+B*a)*ln(cos(d*x+c))/d+b*B*tan(d*x+c)/d

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 42, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.095, Rules used = {3606, 3556} \[ \int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-\frac {(a B+A b) \log (\cos (c+d x))}{d}+x (a A-b B)+\frac {b B \tan (c+d x)}{d} \]

[In]

Int[(a + b*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]

[Out]

(a*A - b*B)*x - ((A*b + a*B)*Log[Cos[c + d*x]])/d + (b*B*Tan[c + d*x])/d

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3606

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[b*d*(Tan[e + f*x]/f), x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rubi steps \begin{align*} \text {integral}& = (a A-b B) x+\frac {b B \tan (c+d x)}{d}+(A b+a B) \int \tan (c+d x) \, dx \\ & = (a A-b B) x-\frac {(A b+a B) \log (\cos (c+d x))}{d}+\frac {b B \tan (c+d x)}{d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.03 (sec) , antiderivative size = 59, normalized size of antiderivative = 1.40 \[ \int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=a A x-\frac {b B \arctan (\tan (c+d x))}{d}-\frac {A b \log (\cos (c+d x))}{d}-\frac {a B \log (\cos (c+d x))}{d}+\frac {b B \tan (c+d x)}{d} \]

[In]

Integrate[(a + b*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]

[Out]

a*A*x - (b*B*ArcTan[Tan[c + d*x]])/d - (A*b*Log[Cos[c + d*x]])/d - (a*B*Log[Cos[c + d*x]])/d + (b*B*Tan[c + d*
x])/d

Maple [A] (verified)

Time = 0.02 (sec) , antiderivative size = 47, normalized size of antiderivative = 1.12

method result size
norman \(\left (a A -B b \right ) x +\frac {b B \tan \left (d x +c \right )}{d}+\frac {\left (A b +B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(47\)
derivativedivides \(\frac {b B \tan \left (d x +c \right )+\frac {\left (A b +B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (a A -B b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(51\)
default \(\frac {b B \tan \left (d x +c \right )+\frac {\left (A b +B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (a A -B b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(51\)
parts \(A a x +\frac {\left (A b +B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {B b \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(51\)
parallelrisch \(\frac {2 A x a d -2 B b d x +A \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) b +B \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a +2 b B \tan \left (d x +c \right )}{2 d}\) \(57\)
risch \(i A b x +i B a x +A a x -B b x +\frac {2 i A b c}{d}+\frac {2 i a B c}{d}+\frac {2 i B b}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A b}{d}-\frac {a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{d}\) \(100\)

[In]

int((a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

(A*a-B*b)*x+b*B*tan(d*x+c)/d+1/2*(A*b+B*a)/d*ln(1+tan(d*x+c)^2)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 50, normalized size of antiderivative = 1.19 \[ \int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {2 \, {\left (A a - B b\right )} d x + 2 \, B b \tan \left (d x + c\right ) - {\left (B a + A b\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right )}{2 \, d} \]

[In]

integrate((a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/2*(2*(A*a - B*b)*d*x + 2*B*b*tan(d*x + c) - (B*a + A*b)*log(1/(tan(d*x + c)^2 + 1)))/d

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 73 vs. \(2 (36) = 72\).

Time = 0.08 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.74 \[ \int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\begin {cases} A a x + \frac {A b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {B a \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - B b x + \frac {B b \tan {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (A + B \tan {\left (c \right )}\right ) \left (a + b \tan {\left (c \right )}\right ) & \text {otherwise} \end {cases} \]

[In]

integrate((a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x)

[Out]

Piecewise((A*a*x + A*b*log(tan(c + d*x)**2 + 1)/(2*d) + B*a*log(tan(c + d*x)**2 + 1)/(2*d) - B*b*x + B*b*tan(c
 + d*x)/d, Ne(d, 0)), (x*(A + B*tan(c))*(a + b*tan(c)), True))

Maxima [A] (verification not implemented)

none

Time = 0.37 (sec) , antiderivative size = 50, normalized size of antiderivative = 1.19 \[ \int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {2 \, B b \tan \left (d x + c\right ) + 2 \, {\left (A a - B b\right )} {\left (d x + c\right )} + {\left (B a + A b\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{2 \, d} \]

[In]

integrate((a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

1/2*(2*B*b*tan(d*x + c) + 2*(A*a - B*b)*(d*x + c) + (B*a + A*b)*log(tan(d*x + c)^2 + 1))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 289 vs. \(2 (42) = 84\).

Time = 0.39 (sec) , antiderivative size = 289, normalized size of antiderivative = 6.88 \[ \int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {2 \, A a d x \tan \left (d x\right ) \tan \left (c\right ) - 2 \, B b d x \tan \left (d x\right ) \tan \left (c\right ) - B a \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right ) \tan \left (c\right ) - A b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right ) \tan \left (c\right ) - 2 \, A a d x + 2 \, B b d x + B a \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) + A b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) - 2 \, B b \tan \left (d x\right ) - 2 \, B b \tan \left (c\right )}{2 \, {\left (d \tan \left (d x\right ) \tan \left (c\right ) - d\right )}} \]

[In]

integrate((a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

1/2*(2*A*a*d*x*tan(d*x)*tan(c) - 2*B*b*d*x*tan(d*x)*tan(c) - B*a*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c
) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)*tan(c) - A*b*log(4*(tan(d*x)^2*tan(c)^2 - 2
*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)*tan(c) - 2*A*a*d*x + 2*B*b*d
*x + B*a*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1)
) + A*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))
 - 2*B*b*tan(d*x) - 2*B*b*tan(c))/(d*tan(d*x)*tan(c) - d)

Mupad [B] (verification not implemented)

Time = 7.18 (sec) , antiderivative size = 55, normalized size of antiderivative = 1.31 \[ \int (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {B\,b\,\mathrm {tan}\left (c+d\,x\right )+\frac {A\,b\,\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )}{2}+\frac {B\,a\,\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )}{2}+A\,a\,d\,x-B\,b\,d\,x}{d} \]

[In]

int((A + B*tan(c + d*x))*(a + b*tan(c + d*x)),x)

[Out]

(B*b*tan(c + d*x) + (A*b*log(tan(c + d*x)^2 + 1))/2 + (B*a*log(tan(c + d*x)^2 + 1))/2 + A*a*d*x - B*b*d*x)/d